/**
 * 
 * 用户相关的请求模块
 */

import axios from '../utils/axios' // 引入axios
// import store from '@/store/index.js'

// 用户登录
export const login = data => { //data是形参，调用login时，需要将这次请求的数据传递过来
    return axios({
        method: 'POST',
        url: '/v1_0/authorizations',
        data: data
    })
};
// 获取短信验证码
export const sendSms = mobile => { //data是形参，调用login时，需要将这次请求的数据传递过来
    return axios({
        method: 'GET',
        url: `/v1_0/sms/codes/${mobile}`,
    })
};
// 获取用户自己的信息
export const getUserInfo = () => {
    return axios({
        method: 'GET',
        url: `/v1_0/user`,
        // 发送请求头数据
        // headers: {
        // Authorization: `Bearer ${store.state.user.token}`
        // }
    })
};
// 获取用户频道列表
export const getUserchannel = () => {
    return axios({
        method: 'GET',
        url: '/v1_0/user/channels',
    })
};
// 关注用户
export const addFollow = target => {
    return axios({
        method: 'POST',
        url: `/v1_0/user/followings`,
        data: {
            target
        }
    })
};

// 取消关注用户
export const DELETEFollow = target => {
    return axios({
        method: 'DELETE',
        url: `/v1_0/user/followings/${target}`, //target目标用户（被取消关注的用户id）

    })
};

// 获取用户个人资料
export const getUserdata = () => {
    return axios({
        method: 'GET',
        url: '/v1_0/user/profile'
    })
};

// 更新用户资料
export const updateUserdata = data => {
    return axios({
        method: 'PATCH',
        url: '/v1_0/user/profile',
        data
    })
};

/**
 * 更新用户照片资料
 */
export const updateUserPhoto = data => {
    return axios({
        method: 'PATCH',
        url: '/v1_0/user/photo',
        data
    })
}